package cn.z2huo.knowledge.basic.bit.hashmap;

/**
 * <p>
 *
 * @author z2huo
 */
class HashMapTableIndexTest {

    public static void main(String[] args) {
        System.out.println(Integer.toBinaryString(16));
        System.out.println(Integer.toBinaryString(32));
        System.out.println();

        test("name");
        test("age");
    }

    private static void test(String key) {
        int hash = key.hashCode();
        System.out.println(hash);
        System.out.println(Integer.toBinaryString(hash));
        System.out.println(Integer.toBinaryString(hash & 16));

        int oldIdx = hash & (16 - 1);
        System.out.println(oldIdx);

        int newIndex = hash & (32 - 1);
        System.out.println(newIndex);

        System.out.println(oldIdx + 16);
        System.out.println();
    }
}
